// import bluebird from "bluebird";
// import i18n from "i18n";
// import MD5Tool from "MD5Tool";
import BaseClass from "./BaseClass";

class LZBJPK_App extends cc.Component {
    subGameName: "lzbjpk"; //"子游戏名称";
    lineLevelNum: 0;
    opType: 0;
    mgrs: {}; //存放管理器的

    // 不需要创建单例的API
    apiDict: {};

    NeedCreateList:string[]; 

    public static Instance:LZBJPK_App = null;
    client: {} = null; //当前的client 组件
    protected onLoad(): void {
        if (LZBJPK_App.Instance !== null) {
            this.destroy();
            return;
        }
        this.init();
        LZBJPK_App.Instance = this;        
    }

    private init(){
        // 不需要创建单例的API
        this.apiDict = {
            "BaseClass": BaseClass["BaseClass"],
            "DBBaseClass": BaseClass["DBBaseClass"],
            // "bluebird": bluebird,
            // "i18n": i18n,
            // "MD5": MD5Tool,
        }

        // 需要创建单例的API
        this.NeedCreateList = [
            this.subGameName.toLowerCase() + "_ShareDefine",

            this.subGameName.toLowerCase() + "_ComTool",
            "LocalDataManager",
            this.subGameName.toLowerCase() + "_UtilsWord",

            // 基础模块
            this.subGameName.toLowerCase() + "_SysDataManager",
            this.subGameName.toLowerCase() + "_SysNotifyManager",
            this.subGameName.toLowerCase() + "_ConfirmManager",
            this.subGameName.toLowerCase() + "_ControlManager",
            this.subGameName.toLowerCase() + "_HttpPack",
            this.subGameName.toLowerCase() + "_NetRequest",
            this.subGameName.toLowerCase() + "_NetWork",
            this.subGameName.toLowerCase() + "_NetManager",
            this.subGameName.toLowerCase() + "_SDKManager",
            this.subGameName.toLowerCase() + "_WeChatManager",
            this.subGameName.toLowerCase() + "_WeChatAppManager",
            this.subGameName.toLowerCase() + "_DownLoadMgr",
            this.subGameName.toLowerCase() + "_LocationOnStartMgr",
            this.subGameName.toLowerCase() + "_HotUpdateMgr",

            // 资源模块
            this.subGameName.toLowerCase() + "_SceneManager",
            this.subGameName.toLowerCase() + "_FormManager",
            this.subGameName.toLowerCase() + "_EffectManager",
            this.subGameName.toLowerCase() + "_SoundManager",
            this.subGameName.toLowerCase() + "_AudioManager",
            this.subGameName.toLowerCase() + "_HeadManager",
            // 数据管理器
            this.subGameName.toLowerCase() + "_ServerTimeManager",
            this.subGameName.toLowerCase() + "_HeroAccountManager",
            this.subGameName.toLowerCase() + "_HeroManager",

            this.subGameName.toLowerCase() + "_NativeManager",

            // -----汇总数据管理器----
            this.subGameName.toLowerCase() + "_GameManager",

            // -----牌局相关-------
            this.subGameName.toLowerCase() + "_ShareDefine",
            this.subGameName.toUpperCase() + "PokerCard",
            this.subGameName.toUpperCase() + "RoomMgr",
            this.subGameName.toUpperCase() + "Room",
            this.subGameName.toUpperCase() + "RoomSet",
            this.subGameName.toUpperCase() + "RoomPosMgr",

            // ZJQZSKDefine
            this.subGameName.toUpperCase() + "Define",
            this.subGameName.toUpperCase() + "LogicGame",
            this.subGameName.toUpperCase() + "LogicRank"
        ]
    }  
    
    public addClient(target){
        let name = this.subGameName + "Client";
        this.client[name] = this;
    }

    public getClient(){
        let name = this.subGameName + "Client";
        return  this.client[name];
    }

    /**
     * 
     * @param conName 组件名字，这个名字和subGameName组合就是脚本ts 文件的名字
     * @param mgrCom 脚本组件
     */
    public addCom(conName: string,mgrCom: cc.Component){
        let name = this.subGameName + conName;
        this.mgrs[name] = mgrCom;
    }
}


export let app = LZBJPK_App.Instance;